package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Hotel;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IHotelService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("hotels")
public class HotelController {
    @Autowired
    private IHotelService hotelService;

    /**
     * 全部酒店
     * @param qo
     * @return
     */
    @GetMapping
    public Object list(QueryObject qo){
        //qo.setOrderBy("t.releaseTime desc");
        PageInfo pageInfo = hotelService.queryForList(qo);
        return pageInfo;
    }

    /**
     * 推荐的酒店
     * @param qo
     * @return
     */
    @GetMapping("/commends")
    public Object commends(QueryObject qo){
        //qo.setOrderBy("t.releaseTime desc");
        qo.setState(1);//推荐的酒店
        PageInfo pageInfo = hotelService.queryForList(qo);
        return pageInfo;
    }
    @GetMapping("/{id}")
    public Object hotelRoom(@PathVariable Long id){
        //qo.setOrderBy("t.releaseTime desc");
        Hotel hotel = hotelService.queryByHotelId(id);
        return hotel;
    }

}
